Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to infer the fetcher's key #2067

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Yuddomack
Copy link

Hi!

I am using passing objects feature (https://swr.vercel.app/docs/arguments#passing-objects) like this.

image

Unfortunately, This obviously leads to incorrect execution.
But you won't know until execute project.

because this fetcher infers the type as a bare fetcher, it shows no error information.

but, enable key inference with this update,

image

can be corrected correctly

image

I looked at swr2 (also 1.3), If only a fetcher and a key exist, there is no need to infer that it is a bare fetcher.
so I think it would be better to inform the user that this is an incorrect usage.

Please consider this change.
thank you for read!

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit de625fd:

Sandbox Source
SWR-Basic Configuration
SWR-States Configuration
SWR-Infinite Configuration
SWR-SSR Configuration

@promer94
Copy link
Collaborator

promer94 commented Jul 10, 2022

I think we might still need to keep this overload here for compatibility for now #1640 (comment)

@Yuddomack
Copy link
Author

Thanks for the quick feedback. I'll check it out!

@phaux
Copy link

phaux commented Aug 21, 2022

I understand the compatibility concerns but why can't it be changed in 2.0.0-beta already?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants